﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using TXK;

namespace WindowsFormsApp1
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                DevXMZ devXMZ = new DevXMZ();
                devXMZ.VariableAll.Add(new SiemensVar()
                {
                    VarAddress = "DB1.0",
                    StoreType = StoreType.DataBlock,
                    VarName = "asdf",
                    Value = 3.134,
                    DataType = TXK.CommonBase.DataType.Float,
                    HighAlarmEnable = true,
                    HighAlarmValue = 10,
                    AlarmEnable = true,
                    AlarmType = TXK.CommonBase.AlarmType.条件报警
                }
                );
                devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.4.2", StoreType = StoreType.DataBlock, AlarmType = TXK.CommonBase.AlarmType.离散报警, AlarmEnable = true, Value = "", DiscreteAlarmType = TXK.CommonBase.DiscreteAlarmType.上升沿报警 });
                devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.14", StoreType = StoreType.DataBlock, VarName = "asdf啊", Value = 23.78, DataType = TXK.CommonBase.DataType.Float });
                devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.20", StoreType = StoreType.DataBlock });
                devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "mb20", StoreType = StoreType.Marker });
                devXMZ.AlarmEvent += DevXMZ_AlarmEvent;

                devXMZ.Start();
                //devXMZ.SaveAsJson();
                devXMZ.SaveAsExcel();
                //var res = devXMZ["asdf啊"];
                //  devXMZ.LoadConFigByExcel();
                // var res2 = devXMZ["aa"];
            }
            catch (Exception)
            {

              //  throw;
            }
            
            Application.Run(new Form1());
        }

        private static void DevXMZ_AlarmEvent(object sender, AlarmEventArgs e)
        {
            throw new NotImplementedException();
            
        }
    }
}
